package com.baosf.serviceorder.feign;

import com.baosf.model.product.Product;
import com.baosf.serviceorder.config.OrderServiceConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * OpenFeign 调用客户端
 * configuration = OrderServiceConfig.class 使日志配置生效
 * fallback = ProductFeignClientFallback.class 声明要使用该回调类
 */
@FeignClient(value = "service-product", configuration = OrderServiceConfig.class, fallback = ProductFeignClientFallback.class)
public interface ProductFeignClient {
    // mvc 注解的两套逻辑：
    // 1.标注在 Controller 上，是接收请求
    // 2.标注在 FeignClient 上，是发送请求
    @GetMapping("/product/{id}")
    Product getProduct(@PathVariable("id") Long id);
}
